/*
 * strnlen_s.c - Safe string length with bounds checking
 */

#include "bounds_check.h"
#include <string.h>

int strnlen_s(const char *str, size_t str_size, size_t *result) {
    if (str == NULL || result == NULL) {
        return BOUNDS_CHECK_INVALID_PARAM;
    }

    size_t len = 0;
    while (len < str_size && str[len] != '\0') {
        len++;
    }

    *result = len;
    return BOUNDS_CHECK_SUCCESS;
}